package com.personal.gateway.mapper;

import com.personal.gateway.entity.FlinkCommandHistory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @program: FlinkGateway
 * @description:
 * @author: yangliao
 * @create: 2021-08-23
 */
@Mapper
public interface FlinkCommandHistoryMapper {

    @Insert("INSERT INTO `flink_command_history` " +
            " (`gateway_num`, `type`, `command`, `output`, `user_name`) " +
            "VALUES " +
            " (#{history.gatewayNum}, #{history.type}, #{history.command}, #{history.output}, #{history.userName})")
    int insert(@Param("history") FlinkCommandHistory history);

    @Select("select * from flink_command_history where gateway_num = #{gatewayNum} order by id desc limit 20 ")
    List<FlinkCommandHistory> list(@Param("gatewayNum") String gatewayNum);

    @Select("select * from flink_command_history where id = #{id} ")
    FlinkCommandHistory getHistoryById(@Param("id") Integer id);

}
